f = open(r"D:\python PPT\实验报告\beat it_eng.txt", encoding="utf-8")
a = f.read()
for k in '.-':
    b = a.replace(k, " ")
a = b.split()

print("分割出来的单词", a)

words_dic = {}

for x in a:
    if x in words_dic:
        words_dic[x] += 1

    else:
        words_dic[x] = 1

print("单词   出现次数")
for key in words_dic:
    print('%s   %s' %(key, words_dic[key]))


f.close()
